VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "itgcontrols.ocx"
Begin VB.Form frmPMSLister 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Transaction List (Expenses)"
   ClientHeight    =   5130
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5055
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmPMSLister.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5130
   ScaleWidth      =   5055
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame Frame1 
      Height          =   4545
      Left            =   60
      TabIndex        =   3
      Top             =   60
      Width           =   4935
      Begin MSComctlLib.ListView lvwList 
         Height          =   4155
         Left            =   120
         TabIndex        =   0
         Top             =   240
         Width           =   1500
         _ExtentX        =   2646
         _ExtentY        =   7329
         View            =   3
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         FullRowSelect   =   -1  'True
         GridLines       =   -1  'True
         HotTracking     =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   0
         NumItems        =   1
         BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Text            =   "Reference No."
            Object.Width           =   2540
         EndProperty
      End
      Begin ITGControls.ITGTextBox txtSMCode 
         Height          =   285
         Left            =   1980
         TabIndex        =   5
         Top             =   1005
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Type"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
      End
      Begin ITGControls.ITGDateBox dtbDate 
         Height          =   285
         Left            =   3015
         TabIndex        =   6
         Tag             =   "Order Date"
         Top             =   1365
         Width           =   1350
         _ExtentX        =   2381
         _ExtentY        =   503
         Enabled         =   0   'False
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   ""
         SendKeysTab     =   -1  'True
         Mandatory       =   -1  'True
         DatePicker      =   0   'False
      End
      Begin ITGControls.ITGLabel ITGLabel4 
         Height          =   285
         Left            =   2010
         TabIndex        =   7
         Top             =   1365
         Width           =   915
         _ExtentX        =   1614
         _ExtentY        =   503
         Caption         =   "Ref. Date"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin ITGControls.ITGTextBox txtBalance 
         Height          =   285
         Left            =   1980
         TabIndex        =   9
         Top             =   3960
         Width           =   2385
         _ExtentX        =   3995
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         DataType        =   1
         DecimalPlace    =   2
         Locked          =   -1  'True
         Label           =   "Amount"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1325
      End
      Begin VB.Line Line1 
         X1              =   2400
         X2              =   4800
         Y1              =   1980
         Y2              =   1980
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Details"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   195
         Index           =   2
         Left            =   1740
         TabIndex        =   8
         Top             =   1875
         Width           =   585
      End
      Begin VB.Label lblClient 
         Alignment       =   2  'Center
         Caption         =   "Client"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   555
         Left            =   1800
         TabIndex        =   4
         Top             =   300
         Width           =   2970
      End
   End
   Begin ITGControls.ITGCommandButton cmdCancel 
      Height          =   345
      Left            =   3795
      TabIndex        =   2
      Top             =   4695
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   609
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&Cancel"
   End
   Begin ITGControls.ITGCommandButton cmdOK 
      Height          =   345
      Left            =   2535
      TabIndex        =   1
      Top             =   4695
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   609
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&OK"
   End
End
Attribute VB_Name = "frmPMSLister"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit

Enum ePMSPick
    ToRFP
    ToJV
    ToVoucher
    ToSOE1
    ToPayable
End Enum

Public mPMSPick As ePMSPick
Public mcInvNo As String
Public mdDate As String
Public mnBalance As Double
Public mnTPCBalance As Double

Private oConnection As New clsConnection
Private connList As New ADODB.Connection

Private Sub cmdCancel_Click()
    Set frmPMSLister = Nothing
    vStrContainer1 = ""
    Unload Me
End Sub

Private Sub cmdOK_Click()
    If lvwList.ListItems.Count = 0 Then
        Unload Me
        Exit Sub
    End If
    If dtbDate.Text = "__/__/____" Then
        MsgBox "Please select invoice number from the list.", vbInformation, msgTtl
        Exit Sub
    End If
    
    If mPMSPick = ToRFP Then
        'frmAPRFP.AddDetailsFromExpenses mcInvNo, mdDate, mnBalance
    ElseIf mPMSPick = ToJV Then
        vStrContainer1 = mcInvNo
    ElseIf mPMSPick = ToVoucher Then
        'frmAPVoucherMain.AddDetailsFromExpenses mcInvNo, mdDate, mnBalance
    ElseIf mPMSPick = ToSOE1 Then
        'vStrContainer1 = mcInvNo
    ElseIf mPMSPick = ToPayable Then
        vStrContainer1 = mcInvNo
    End If
    Unload Me
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyEscape Then
        Unload Me
        Set frmPMSLister = Nothing
    End If
End Sub

Private Sub Form_Load()
Dim rsSIList As New Recordset

    'Client Code = "RepName"
    Select Case mPMSPick
        Case ToRFP
            sSQL = "SELECT cTranNo AS cInvNo FROM PMS_EXPENSE WHERE cPJMNo = '" & Trim(RepName) & "' AND cCompanyID = '" & COID & "' AND cType <> 'Liquidation' " & _
                    " AND cTranNo not in (SELECT cReference FROM RFP WHERE cType IN ('Reimbursement','Replenishment'))"
            Me.Caption = "Summary of Expenses List (Project)"
        Case ToJV                                                                           ' ,cPJMNo = '" & Trim(RepName) & "' AND
            sSQL = "SELECT cTranNo AS cInvNo FROM PMS_EXPENSE WHERE cCompanyID = '" & COID & "' AND cType = 'Liquidation' " & _
                    " AND cTranNo not in (SELECT cReference FROM GL WHERE cCode = 'LOE' AND cReference is not null) AND lApproved = 1"
            Me.Caption = "Summary of Expenses List (Project)"
        Case ToVoucher
            sSQL = "SELECT cTranNo AS cInvNo FROM PMS_EXPENSE WHERE cPJMNo = '" & Trim(RepName) & "' AND cCompanyID = '" & COID & "' AND cType <> 'Liquidation' " & _
                    " AND cTranNo not in (SELECT cRefNo FROM VOUCHER_EXPENSE WHERE cType IN ('Reimbursement','Replenishment')) AND lApproved = 1"
            Me.Caption = "Summary of Expenses List (Project)"
        Case ToSOE1
            sSQL = "SELECT cTranNo AS cInvNo FROM PMS_EXPENSE WHERE cPJMNo = '" & Trim(RepName) & "' AND cCompanyID = '" & COID & "' AND cType <> 'Liquidation' " & _
                    " AND lApproved = 1"
            Me.Caption = "Summary of Expenses List (Project)"
        Case ToPayable
            sSQL = "SELECT cTranNo AS cInvNo FROM PAYABLES WHERE cCode = '" & Trim(RepName) & "' AND cCompanyID = '" & COID & "'" & _
                    " AND lApproved = 1"
            Me.Caption = "Payable Setup List (Project)"
    End Select
    
    oConnection.OpenNewConnection connList
    
    rsSIList.Open sSQL, connList, adOpenForwardOnly, adLockReadOnly
    
    lvwList.ListItems.Clear
    
    Do Until rsSIList.EOF
        Set itmX = lvwList.ListItems.Add(, , Trim(rsSIList!cInvNo))
        rsSIList.MoveNext
    Loop
    
    rsSIList.Close
    Set rsSIList = Nothing
    
    If mPMSPick = ToPayable Then
        lblClient = RepName & " - " & GetValueFrTable("cName", "CLIENT_SUPPLIER_NT", "cCode = '" & Trim(RepName) & "'")
    Else
        lblClient = RepName & " - " & GetValueFrTable("cEmpName", "EMPLOYEE", "cEmpCode = '" & Trim(RepName) & "'")
    End If
    
    If lvwList.ListItems.Count <> 0 Then lvwList_ItemClick lvwList.ListItems(lvwList.SelectedItem.Index)

End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set connList = Nothing
    RepName = ""
    cString = ""
End Sub

Private Sub lvwList_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    lvwList.Sorted = True
    lvwList.SortKey = ColumnHeader.Index - 1
End Sub

Private Sub lvwList_ItemClick(ByVal Item As MSComctlLib.ListItem)
    If lvwList.ListItems.Count = 0 Then Exit Sub
    mcInvNo = Trim(lvwList.SelectedItem)
    ListInvDetail (Trim(lvwList.SelectedItem))
End Sub

'Show invoice details
Sub ListInvDetail(InvNo As String)
On Error Resume Next
Dim rsList As New Recordset

    Select Case mPMSPick
        Case ToRFP
            sSQL = "SELECT cType, dDate, cDivisionID, nGross FROM PMS_EXPENSE " & _
                   "WHERE cTranNo = '" & Trim(InvNo) & "' AND cCompanyID = '" & COID & "'"
        Case ToJV
            sSQL = "SELECT cType, dDate, cDivisionID, nGross FROM PMS_EXPENSE " & _
                   "WHERE cTranNo = '" & Trim(InvNo) & "' AND cCompanyID = '" & COID & "'"
        Case ToVoucher
            sSQL = "SELECT cType, dDate, cDivisionID, nGross FROM PMS_EXPENSE " & _
                   "WHERE cTranNo = '" & Trim(InvNo) & "' AND cCompanyID = '" & COID & "'"
        Case ToPayable
            sSQL = "SELECT dDate, cCode, nAmount as nGross FROM PAYABLES " & _
                   "WHERE cTranNo = '" & Trim(InvNo) & "' AND cCompanyID = '" & COID & "'"
        Case ToSOE1
            sSQL = "SELECT cType, dDate, cDivisionID, nGross FROM PMS_EXPENSE " & _
                   "WHERE cTranNo = '" & Trim(InvNo) & "' AND cCompanyID = '" & COID & "'"
    End Select
    
    oConnection.OpenNewConnection connList
    
    rsList.Open sSQL, connList, adOpenForwardOnly, adLockReadOnly
    
    With rsList
  
        txtSMCode = Trim(!cType) & ""
        dtbDate.Text = Format(!dDate, "MM/dd/yyyy")
        mdDate = Format(!dDate, "MM/dd/yyyy")
        txtBalance = !nGross
        mnBalance = !nGross
    End With
        
    rsList.Close
    Set rsList = Nothing

End Sub

Private Sub lvwList_KeyPress(KeyAscii As Integer)
    If lvwList.ListItems.Count = 0 Then Exit Sub
    If KeyAscii = 13 Then
        lvwList_ItemClick lvwList.ListItems(lvwList.SelectedItem.Index)
        SendKeys "{Tab}"
    End If
End Sub
